package com.bjsxt;

/**
 * @Author lichunlong lcl253137@alibaba-inc.com
 * @Desc 单例模式 - 懒汉式
 * @Date 2021-10-21
 */
public class SingletonDemo02 {

    /**
     * 类初始化时不初始化该对象，延迟加载
     */
    private static SingletonDemo02 instance;

    /**
     * 私有化构造器
     */
    private SingletonDemo02() {

    }

    /**
     * 方法同步，调用效率低
     */
    public static synchronized SingletonDemo02 getInstance() {
        if (null == instance) {
            instance = new SingletonDemo02();
        }

        return instance;
    }
}